package crudfx.util;
import java.awt.dnd.*;
import java.awt.datatransfer.*;
import java.io.*;
import java.awt.*;
import javax.swing.*;
import java.net.*;
/**
 * @profile desktop
 * @author Sergey Surikov
 */
public class DragCatcher{
    public-init var component:Component;
    public-init var onDrop:function(text:String[]):Void;
    init{
        var dragSourceListener:DragSourceListener=DragSourceListener{
            override public function dragEnter(evt:DragSourceDragEvent):Void{println("dragEnter:{evt}");}
            override public function dragOver(evt:DragSourceDragEvent):Void{println("dragOver:{evt}");}
            override public function dragExit(evt:DragSourceEvent):Void{println("dragExit:{evt}");}
            override public function dropActionChanged(evt:DragSourceDragEvent):Void{println("dropActionChanged:{evt}");}
            override public function dragDropEnd(evt:DragSourceDropEvent):Void{println("dragDropEnd:{evt}");}
            };
        var dragSource:DragSource=new DragSource();
        dragSource.addDragSourceListener(dragSourceListener);
        var dragGestureListener:DragGestureListener=DragGestureListener{
            override public function dragGestureRecognized(dge:DragGestureEvent):Void{
                println("dragGestureRecognized:{dge}");
                var stringSelection:StringSelection=new StringSelection("dsasrb");
                dge.startDrag(null, stringSelection);
                }
            };
        dragSource.createDefaultDragGestureRecognizer(
            component
            ,DnDConstants.ACTION_COPY_OR_MOVE
            ,dragGestureListener)
        }
    }
